package com.bwie.auth.controller;

import com.bwie.auth.service.AuthService;
import com.bwie.common.domain.User;
import com.bwie.common.domain.request.UserRequest;
import com.bwie.common.domain.response.UserResponse;
import com.bwie.common.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author：ShenJiaFeng
 * @Package：com.bwie.auth.controller
 * @Project：zg6_week11
 * @name：AuthController
 * @Date：2024/4/25 9:26
 */
@RestController
@RequestMapping("/auth")
public class AuthController {
    @Autowired
    private AuthService authService;

    /**
     * 登录
     * @param userRequest
     * @return
     */
    @PostMapping("/login")
    public Result<UserResponse> login(@RequestBody UserRequest userRequest){
        return authService.login(userRequest);
    }

    @PostMapping("/userInfo")
    public Result<User> userInfo(){
        return Result.success(
          authService.userInfo()
        );
    }
}
